thumbstick2 2.2.0
Loading...
Searching...
No Matches
thumbstick2.h File Reference

This file contains API for Thumbstick 2 Click Driver. More...

#include "drv_digital_out.h"
#include "drv_digital_in.h"
#include "drv_spi_master.h"
#include "spi_specifics.h"
#include "drv_pwm.h"

Go to the source code of this file.

Data Structures

struct  thumbstick2_t
 Thumbstick 2 Click context object. More...
struct  thumbstick2_cfg_t
 Thumbstick 2 Click configuration object. More...

Macros

#define THUMBSTICK2_ADC_START_BIT   0x01
 Thumbstick 2 ADC calculation values.
#define THUMBSTICK2_ADC_SINGLE_ENDED   0x80
#define THUMBSTICK2_ADC_CHANNEL_X   0x00
#define THUMBSTICK2_ADC_CHANNEL_Y   0x40
#define THUMBSTICK2_ADC_DATA_RESOLUTION   0x0FFF
#define THUMBSTICK2_ADC_DATA_RESOLUTION_HALF   ( ( float ) THUMBSTICK2_ADC_DATA_RESOLUTION / 2 )
#define THUMBSTICK2_RADIANS_TO_DEGREES   57.295779513
 Thumbstick 2 angle and position calculation values.
#define THUMBSTICK2_ANGLE_ZERO_OFFSET   180.0
#define THUMBSTICK2_PI_RAD_OFFSET   1.0
#define THUMBSTICK2_NEUTRAL_POSITION_OFFSET   ( ( float ) THUMBSTICK2_ADC_DATA_RESOLUTION / 8 )
#define THUMBSTICK2_FULL_ANGLE   360.0f
#define THUMBSTICK2_ZERO_ANGLE   0.0f
#define THUMBSTICK2_ANGLE_POSITION_STEP   45.0f
#define THUMBSTICK2_POSITION_NEUTRAL   0
 Thumbstick 2 position values.
#define THUMBSTICK2_POSITION_UP   1
#define THUMBSTICK2_POSITION_UPPER_LEFT   2
#define THUMBSTICK2_POSITION_LEFT   3
#define THUMBSTICK2_POSITION_LOWER_LEFT   4
#define THUMBSTICK2_POSITION_DOWN   5
#define THUMBSTICK2_POSITION_LOWER_RIGHT   6
#define THUMBSTICK2_POSITION_RIGHT   7
#define THUMBSTICK2_POSITION_UPPER_RIGHT   8
#define THUMBSTICK2_PWM_DEF_FREQ   20000
 Thumbstick 2 default PWM frequency.
#define THUMBSTICK2_PWM_MIN_DUTY   0.0
#define THUMBSTICK2_PWM_MAX_DUTY   1.0
#define THUMBSTICK2_SET_DATA_SAMPLE_EDGE   SET_SPI_DATA_SAMPLE_EDGE
 Data sample selection.
#define THUMBSTICK2_SET_DATA_SAMPLE_MIDDLE   SET_SPI_DATA_SAMPLE_MIDDLE
#define THUMBSTICK2_MAP_MIKROBUS(cfg, mikrobus)
 MikroBUS pin mapping.

Enumerations

enum  thumbstick2_return_value_t { THUMBSTICK2_OK = 0 , THUMBSTICK2_ERROR = -1 }
 Thumbstick 2 Click return value data. More...

Functions

void thumbstick2_cfg_setup (thumbstick2_cfg_t *cfg)
 Thumbstick 2 configuration object setup function.
err_t thumbstick2_init (thumbstick2_t *ctx, thumbstick2_cfg_t *cfg)
 Thumbstick 2 initialization function.
err_t thumbstick2_read_raw_adc (thumbstick2_t *ctx, uint16_t *raw_x, uint16_t *raw_y)
 Thumbstick 2 read raw adc function.
float thumbstick2_get_angle (uint16_t raw_x, uint16_t raw_y)
 Thumbstick 2 get angle function.
uint8_t thumbstick2_get_position (uint16_t raw_x, uint16_t raw_y)
 Thumbstick 2 get position function.
err_t thumbstick2_set_duty_cycle (thumbstick2_t *ctx, float duty_cycle)
 Thumbstick 2 set duty cycle function.
err_t thumbstick2_pwm_stop (thumbstick2_t *ctx)
 Thumbstick 2 stop PWM function.
err_t thumbstick2_pwm_start (thumbstick2_t *ctx)
 Thumbstick 2 start PWM function.
uint8_t thumbstick2_get_sw_pin (thumbstick2_t *ctx)
 Thumbstick 2 get SW pin function.

Detailed Description

This file contains API for Thumbstick 2 Click Driver.

Enumeration Type Documentation

◆ thumbstick2_return_value_t

Thumbstick 2 Click return value data.

Predefined enum values for driver return values.

Enumerator
THUMBSTICK2_OK 
THUMBSTICK2_ERROR